package com.szh.cloud.spring.util;

import com.obs.services.ObsClient;
import com.obs.services.model.ObjectListing;
import com.obs.services.model.ObsObject;

import java.util.List;

public class ObsUtil {
    private static final String endpoint="obs.cn-north-4.myhuaweicloud.com";
    private static final String ak = "1Q9D8P38B1M5WGDVI4IR";
    private static final String sk = "ccuYQWe0TzDXNsixDglgKNzqzLPMCbR0GtRysxWm";
    private static final String bucketName = "java-1202";

    public static void main(String[] args) {
        ObsClient obsClient = new ObsClient(ak,sk,endpoint);
        ObjectListing list = obsClient.listObjects(bucketName);
        List<ObsObject> listObjects = list.getObjects();
        for(ObsObject obsObject:listObjects){
            System.out.println("obsKey:" + obsObject.getObjectKey());
            System.out.println("obsSize:" + obsObject.getMetadata().getContentLength());
        }
    }
}
